<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var reg = /^\d*$/;
        function f() {
            var s1 = document.getElementById("s1");
            var number=0;
                var strings = s1.innerHTML.split(">");
                for (var i=0;i<strings.length;i++){
                        var split = strings[i].split("<");
                        for (var j=0;j<split.length;j++){
                            if (reg.test(split[j])) {
                                number += Number(split[j]);
                            }
                        }
                    }
            alert(number);
                }
    </script>
</head>
<body onload="f()">
<div id="s1">
    <font>500</font>
    <span>20</span>
    <div>1</div>
</div>
</body>
</html>